package accx

import (
	"accx/appFramework/m_config"
	"accx/utils/httpClient"
	"bytes"
	"encoding/json"
	"github.com/cihub/seelog"
	"net/http"
)

type UserDeregist struct {
	StaticIpSegment []string `json:"staticIpSegment"`
}

func Deregist(staticIpSegment []string) {
	var userDeregist UserDeregist
	userDeregist.StaticIpSegment = append(userDeregist.StaticIpSegment, staticIpSegment...)
	cli := httpClient.NewHttp2Client()
	marshalData, _ := json.Marshal(userDeregist)
	ip := m_config.MyAccxData.ServiceIp
	req, err := http.NewRequest("PUT", "http://"+ip+":8100"+"/coreNetwork/wxCm/roleInfo", bytes.NewReader(marshalData))
	if err != nil {
		seelog.Error("Amf UserDeregist request is err:", err)
		return
	}
	resp, err := cli.DoRequest(req)
	if err != nil {
		seelog.Error("Oam DoRequest is err:", err)
		return
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		seelog.Error("Amf UserDeregist resp is err")
	}
}
